<template>
    <div class="setInfomation">
        <IHeader class="header" back="true" title="申请入驻"></IHeader>
        <scroller class="infomation-content">
            <text class="content-tit item-height border-bottom-cecece bgc_fff">基本信息</text>
            <div class="info-list bgc_fff" v-if="settleItem">
                <div class="info-cell flex_row item-height border-bottom-ebebeb">
                    <Label content="身份类型" :error="chooseDesignerType.error"></Label>
                    <text class="choose-word col_868686 item-height" style="padding-right: 44px;" v-if="settleItem.value !== '4'">{{settleItem.description}}</text>
                    <div class="handleChoose flex_row" @click="handleSelectType" v-if="settleItem.value === '4'">
                        <text class="choose-word col_868686">{{chooseDesignerType.value}}</text>
                        <image class="arrow_right_small" :src="imgPath('arrow_right_small.png')"></image>
                    </div>
                </div>
                <div class="info-cell flex_row item-height border-bottom-ebebeb">
                    <Label content="姓名" :error="dataForm.name.error"></Label>
                    <input v-model="dataForm.name.value" @blur="checkName" class="write enterpriseNumber col_868686" placeholder="请输入" type="text">
                </div>
                <div class="info-cell flex_row item-height border-bottom-ebebeb">
                    <Label content="工作年限" :error="dataForm.workYear.error"></Label>
                    <input v-model="dataForm.workYear.value" class="write enterpriseName col_868686" placeholder="请输入工作年限" type="text">
                </div>
                <div class="info-cell flex_row item-height border-bottom-ebebeb">
                    <Label content="联系地址" :error="dataForm.address.error"></Label>
                    <input v-model="dataForm.address.value" class="write enterpriseName col_868686" placeholder="请输入联系地址" type="text">
                </div>
                <div class="info-cell flex_row item-height border-bottom-ebebeb">
                    <Label content="联系电话" :error="dataForm.phone.error"></Label>
                    <text class="choose-word col_868686 item-height" style="padding-right: 44px;">{{dataForm.phone.value}}</text>
                    <!--<text class="choose-word col_868686">{{dataForm.phone.value}}</text>-->
                    <!--<input class="write enterpriseNumber col_868686" v-model="dataForm.phone.value" placeholder="请输入联系电话" @blur="checkPhone" type="tel">-->
                </div>
                <div class="info-cell flex_row item-height border-bottom-ebebeb">
                    <Label content="身份证号码" :error="dataForm.idCard.error"></Label>
                    <input class="write enterpriseName col_868686"  v-model="dataForm.idCard.value" maxlength="18" @blur="checkIDcard" placeholder="请输入身份号码" type="text">
                </div>
                <div class="info-cell flex_row border-bottom-ebebeb no-single">
                    <Label content="身份证照片"></Label>
                    <Question @doclick="handleOpenTip"></Question>
                    <div class="idCardImage-container flex_row">
                        <div @click="singleImageUpload('idCardFront')" class="idCardImage-upload flex_row" v-if="dataForm.idCardFront.value.length <= 0">
                            <image class="image-upload" :src="imgPath('image_upload_1.png')"></image>
                            <text class="upload-word">添加身份证正面</text>
                        </div>
                        <image @click="singleImageUpload('idCardFront')" class="idCardImage-box" :src="dataForm.idCardFront.value" v-if="dataForm.idCardFront.value && dataForm.idCardFront.value.length > 0"></image>
                        <div @click="singleImageUpload('idCardBack')" class="idCardImage-upload flex_row" v-if="dataForm.idCardBack.value.length <= 0">
                            <image class="image-upload" :src="imgPath('image_upload_1.png')"></image>
                            <text class="upload-word">添加身份证反面</text>
                        </div>
                        <image @click="singleImageUpload('idCardBack')" class="idCardImage-box" :src="dataForm.idCardBack.value" v-if="dataForm.idCardBack.value && dataForm.idCardBack.value.length > 0"></image>
                    </div>
                </div>
                <!--<div class="info-cell flex_row item-height border-bottom-ebebeb showForm" @click="seleceShow">-->
                    <!--<Check :show="true" :checked="dataForm.isShow" @doclick="seleceShow"></Check>-->
                    <!--<text class="col_868686 fs_28">是否推送到大师工坊</text>-->
                <!--</div>-->
            </div>
            <text class="content-tit margin_top_24 item-height border-bottom-ebebeb bgc_fff">工作经历</text>
            <timeLine v-if="experienceList && experienceList.length > 0" :list="experienceList" @edit="editExp" :themeColor="themeColor"></timeLine>
            <div class="add-work-experience bgc_fff" @click="addWorkExp">
                <image :src="imgPath('tianjia.png')" class="workImg"></image>
                <text class="worktext">添加工作经历</text>
            </div>
            <div class="person-introduce">
                <Label content="个人宣言标签" class="item-height" :error="dataForm.motto.error"></Label>
                <!--<text class="intro-tit item-height">个人宣言标签</text>-->
                <textarea class="intro-textarea" v-model="dataForm.motto.value" maxlength="30" placeholder="请输入个人宣言标签"></textarea>
            </div>
            <div class="person-introduce">
                <Label content="自我评价" class="item-height" :error="dataForm.evaluation.error"></Label>
                <textarea class="intro-textarea" v-model="dataForm.evaluation.value" maxlength="100" placeholder="请输入自我评价"></textarea>
            </div>
            <div class="person-introduce margin_top_24">
                <text class="intro-tit item-height">个人介绍及成就</text>
                <textarea class="intro-textarea" v-model="dataForm.introduction" maxlength="500" placeholder="请输入个人介绍及成就"></textarea>
                <div class="num">
                    <text class="size">{{countWord}}</text>
                    <text class="size">/500</text>
                </div>
            </div>
            <div class="footer">
                <text class="footerBtn" :class="[ifPress ? 'beforerefer':'afterrefer']" @click="handleSubmit" @touchend="subEnd"  @touchstart="subStart">提交</text>
            </div>
        </scroller>
        <Modal :show="showModal" type="0" :word="errorWord"></Modal>
        <!--身份类型弹窗-->
        <wxc-popup popup-color="#fff" :show="typeSelectShow" pos="right" >
                <div class="dialog-content">
                <IHeader class="header" back="true" close="true" title="选择身份类型" @closeDialog="closeTypeDialog"></IHeader>
                <list class="enterprise-list">
                    <cell class="enterprise-item" @click="chooseThisEnterprise(item,index)" :class="[ifPress ?  'afterpress': 'beforepress']" @touchend="typeTouchEnd()"  @touchstart="typeTouchStart(item, index)"  v-for="(item, index) in personList" :key="index">
                        <text  class="enterprise-name item-height col_464646" :class="[(index === personList.length - 1) ? '' : 'border-bottom-cecece']">{{item.name}}</text>
                    </cell>
                </list>
            </div>
        </wxc-popup>
        <!--添加工作经历弹窗-->
        <wxc-popup popup-color="#fff" :show="workExpShow" @wxcPopupOverlayClicked="closeTypeDialog" pos="right" >
            <IHeader class="header" back="true" close="true" title="工作经历" save="true" @doSave="savePersonalExp" @closeDialog="closeTypeDialog"></IHeader>
            <scroller class="dialog-content bgc_f5f5f5">
                <div class="bgc_fff">
                    <div class="info-cell flex_row item-height border-bottom-ebebeb companyName">
                        <Label content="企业名称" :error="expObject.companyName.error"></Label>
                        <input v-model="expObject.companyName.value" class="write enterpriseName col_868686" placeholder="请输入企业名称" type="text">
                    </div>
                    <div class="info-cell flex_row item-height border-bottom-ebebeb">
                        <Label content="职位名称" :error="expObject.positionName.error"></Label>
                        <input v-model="expObject.positionName.value" class="write enterpriseName col_868686" placeholder="请输入" type="text">
                    </div>
                    <div class="info-cell flex_row item-height border-bottom-ebebeb">
                        <Label content="开始时间" :error="expObject.startTime.error"></Label>
                        <div class="handleChoose flex_row" @click="handleSelectDate('startTime')">
                            <text class="choose-word col_868686">{{expObject.startTime.value}}</text>
                            <image class="arrow_right_small" :src="imgPath('arrow_right_small.png')"></image>
                        </div>
                    </div>
                    <div class="info-cell flex_row item-height border-bottom-ebebeb"  >
                        <Label content="结束时间" :error="expObject.endTime.error"></Label>
                        <div class="handleChoose flex_row" @click="handleSelectDate('endTime')">
                            <text class="choose-word col_868686">{{expObject.endTime.value}}</text>
                            <image class="arrow_right_small" :src="imgPath('arrow_right_small.png')"></image>
                        </div>
                    </div>
                    <div class="info-cell flex_row item-height border-bottom-ebebeb">
                        <Label content="工作地点" :error="expObject.workPlace.error"></Label>
                        <input v-model="expObject.workPlace.value" class="write enterpriseName col_868686" placeholder="请输入" type="text">
                    </div>
                </div>
                <div class="person-introduce work-con margin_top_24">
                    <text class="intro-tit item-height">工作内容</text>
                    <textarea class="intro-textarea" v-model="expObject.workContent" maxlength="500" placeholder="请输入工作内容"></textarea>
                    <div class="num">
                        <text class="size">{{contentWord}}</text>
                        <text class="size">/500</text>
                    </div>
                </div>
                <div class="delete">
                    <text class="deletetext" @click="deleteExp">删除工作经历</text>
                </div>
            </scroller>
        </wxc-popup>
        <!--示例弹窗-->
        <wxc-popup popup-color="#fff" :show="expSelectShow" pos="right">
            <div class="dialog-content">
                <IHeader class="header" back="true" close="true" title="图片要求" @closeDialog="closeExpShow"></IHeader>
                <div class="popup-box">
                    <image class="example-image" ref="license" :src="idCardPhotoSrc" @load="loadImage" @click="previewImage"></image>
                    <div class="example-tip">
                        <text class="tip-header">拍照实例：身份证正面</text>
                        <text class="tip-item">1.请确认身份证各项信息可见，无遮挡</text>
                        <text class="tip-item">2.请上传身份证正反面照片</text>
                        <text class="tip-item">3.不可使用其他证件替代，包括港澳台证件等</text>
                    </div>
                    <Buttons class="margin_top_70" word="已了解，去上传" @doclick="closeExpShow"></Buttons>
                </div>
            </div>
        </wxc-popup>
        <!--loading-->
        <wxc-loading :show="loadingShow" :need-mask="needMask"></wxc-loading>
        <!--图片预览-->
        <Preview :show="previewShow" :src="imageSrc" @hidePreview="hidePreview"></Preview>
    </div>
</template>

<script>
import { WxcPopup, WxcLoading } from 'weex-ui'
import IHeader from '@/components/header'
import Check from '@/components/check'
import Label from '@/components/label'
import Question from '@/components/question'
import timeLine from '@/components/timeLine'
import Modal from '@/components/modal'
import Buttons from '@/components/buttons'
import Preview from '@/components/preview'
import { validatenull, isvalidatemobile, validateIdCardNumber, validatename } from '@/util/validate'
import { personalSettle, queryPersonalExp, addPersonalExp, deletePersonalExp, modifyPersonalExp } from '@/api/user'
import { fileUpload } from '@/api/common'
import Nat from 'natjs'
const picker = weex.requireModule('picker')
const modal = weex.requireModule('modal')
const animation = weex.requireModule('animation')

export default {
  name: 'setInfomation',
  data () {
    return {
      information: null, // 基础信息
      loadingShow: false, // loading
      needMask: true,
      settleItem: {}, // 路由传参
      hasAddr: true, // 是否传地址
      dataForm: {
        name: {
          value: '',
          name: '姓名',
          error: false
        }, // 姓名
        workYear: {
          value: '',
          name: '工作年限',
          error: false
        }, // 工作年限
        address: {
          value: '',
          name: '联系地址',
          error: false
        }, // 联系地址
        phone: {
          value: '',
          name: '联系电话',
          error: false
        }, // 联系电话
        idCard: {
          value: '',
          name: '身份证号码',
          error: false
        }, // 身份证号码
        idCardFront: {
          value: '',
          name: '身份证正面',
          error: false
        }, // 身份证照片正面
        idCardBack: {
          value: '',
          name: '身份证反面',
          error: false
        }, // 身份证照片反面
        // idCardFront: 'http://yyk-upload.oss-cn-shenzhen.aliyuncs.com/app/image/20181026/c25eaad7b1764e9aa1ed030dd421bf66.png', // 身份证照片正面
        // idCardBack: 'http://yyk-upload.oss-cn-shenzhen.aliyuncs.com/app/image/20181026/c25eaad7b1764e9aa1ed030dd421bf66.png', // 身份证照片反面
        motto: {
          value: '',
          name: '个人宣言标签',
          error: false
        }, // 个人宣言标签
        evaluation: {
          value: '',
          name: '自我评价',
          error: false
        }, // 自我评价
        introduction: '' // 个人介绍及成就
      },
      expSelectShow: false, // 示例弹窗
      idCardPhotoSrc: 'http://yyk-upload.oss-cn-shenzhen.aliyuncs.com/app/image/20181026/c25eaad7b1764e9aa1ed030dd421bf66.png', // 示例
      imageSrc: '', // 预览地址
      previewShow: false, // 预览显示
      ifPress: false, // 点击效果
      addname: {}, // 设计师名称
      typeSelectShow: false, // 选择公司类型弹窗显示
      personList: [{ name: '专职设计师', type: 1 }, { name: '工厂设计师 ', type: 2 }, { name: '兼职设计师', type: 3 }], // 企业类型列表
      chooseDesignerType: {
        value: '请选择',
        type: -1,
        error: false
      }, // 设计师类型
      addval: {}, // 判断设计师的选中和未选中的样式
      workExpShow: false, // 添加工作经历的隐现
      showModal: false,
      errorWord: '', // 错误提示
      themeColor: {
        lineColor: '#cecece'
      },
      expId: '', // 经历Id
      expObject: {
        companyName: {
          value: '',
          name: '企业名称',
          error: false
        }, // 企业名称
        positionName: {
          value: '',
          name: '职位名称',
          error: false
        }, // 职位名称
        startTime: {
          // value: '请选择',
          value: '请选择',
          name: '开始时间',
          error: false
        }, // 开始时间
        endTime: {
          // value: '请选择',
          value: '请选择',
          name: '结束时间',
          error: false
        }, // 结束时间
        workPlace: {
          value: '',
          name: '工作地点',
          error: false
        }, // 工作地点
        workContent: '' // 工作内容
      }, // 经历对象
      queryExpList: [], // 获取到的经历列表
      experienceList: [] // 经历列表
    }
  },
  created () {
    this.settleItem = this.$route.query.item // 传参的地址
    this.dataForm.phone.value = this.$route.query.tel // 传参的电话
  },
  mounted () {
    const that = this
    that.getPersonalExperience()
  },
  computed: {
    countWord () {
      return this.dataForm.introduction.length
    },
    contentWord () {
      return this.expObject.workContent.length
    }
  },
  methods: {
    handleOpenTip () { // 打开示例
      this.expSelectShow = true
    },
    closeExpShow () { // 关闭示例
      this.expSelectShow = false
    },
    previewImage (e) { // 图片预览
      const view = e.target
      let url = ''
      if (weex.config.env.platform === 'Web') {
        url = view.getAttribute('src')
      } else {
        url = view.attr.src
      }
      this.imageSrc = url
      this.previewShow = true
    },
    hidePreview () { // 隐藏预览
      this.previewShow = false
    },
    loadImage (event) { // 图片初始化大小
      let els = this.$refs.license
      let k = event.size.naturalWidth / event.size.naturalHeight
      // els.style.width = '650px'
      // els.style.height = parseInt(650 / k) + 'px'
      // els.style.height = 650 / k + '                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                '
      animation.transition(els, {
        styles: {
          width: parseInt(420 * k) + 'px',
          height: 420 + 'px'
        },
        duration: 50, // ms
        timingFunction: 'ease',
        needLayout: true,
        delay: 0 // ms
      }, function () {})
    },
    getPersonalExperience () { // 获取个人经历
      const that = this
      that.loadingShow = true
      that.$api.get(queryPersonalExp, {}, (res) => {
        let list = res.data
        that.queryExpList = list
        that.experienceList = []
        list.forEach((item) => {
          let obj = {
            date: item.startTime + ' - ' + item.endTime,
            desc: item.workContent,
            title: item.workPlace + ' / ' + item.positionName
          }
          that.experienceList.push(obj)
        })
        that.workExpShow = false
        that.loadingShow = false
      }, () => {
        that.loadingShow = false
      }, true)
    },
    addWorkExp () { // 添加工作经历点击事件
      this.expId = ''
      this.workExpShow = true
    },
    checkName () { // 姓名验证
      const that = this
      let val = that.dataForm.name.value
      if (!validatename(val)) {
        that.dataForm.name.error = true
        that.showModal = true
        that.errorWord = '姓名格式有误'
      }
      that.dataForm.name.error = false
      that.showModal = false
    },
    checkPhone () { // 手机号验证
      const that = this
      let tel = that.dataForm.phone.value
      const res = isvalidatemobile(tel)
      if (!res.result) {
        that.errorWord = res.msg
        that.showModal = true
        return
      }
      that.showModal = false
    },
    checkIDcard () { // 身份证验证
      const that = this
      let idCardVal = that.dataForm.idCard.value
      const res = validateIdCardNumber(idCardVal)
      if (!res) {
        that.showModal = true
        that.errorWord = '身份证格式有错误'
        return
      }
      that.showModal = false
    },
    handleSelectType () { // 选择企业类型
      this.typeSelectShow = true
    },
    closeTypeDialog () { // 关闭类型选择弹窗
      this.typeSelectShow = false
      this.workExpShow = false
    },
    chooseThisEnterprise (item) { // 选中类型后
      this.chooseDesignerType.value = item.name
      this.chooseDesignerType.type = item.type
      this.typeSelectShow = false
    },
    singleImageUpload (type) { // 单张图片上传
      const that = this
      Nat.image.pick({
        showCamera: true
      }, (err, ret) => {
        if (err) {
          modal.toast({
            message: '[ERROR] ' + JSON.stringify(err)
          })
          return
        }
        that.loadingShow = true
        let path = ret.paths[0]
        Nat.upload(that.$api.url + fileUpload, {
          path: path
        }, (errs, res) => {
          if (errs) {
            modal.toast({
              message: '[ERROR] ' + JSON.stringify(errs)
            })
            return
          }
          if (res.ok) {
            let data = JSON.parse(res.data)
            let imageUrl = data.data
            for (let j in that.dataForm) {
              if (type === j) {
                that.dataForm[j].value = imageUrl
              }
            }
          }
        })
        that.loadingShow = false
      })
    },
    editExp (inx) {
      const that = this
      let datas = that.queryExpList[inx]
      that.expId = datas.id
      that.expObject.companyName.value = datas.companyName
      that.expObject.positionName.value = datas.positionName
      that.expObject.startTime.value = datas.startTime
      that.expObject.endTime.value = datas.endTime
      that.expObject.workPlace.value = datas.workPlace
      that.expObject.workContent = datas.workContent
      that.workExpShow = true
    },
    handleSelectDate (type) { // 选择时间
      const that = this
      let date = '' // 日期
      picker.pickDate({
        value: date
      }, e => {
        if (e.result === 'success') {
          date = e.data
          for (let i in that.expObject) {
            if (type === i) {
              that.expObject[i].value = date
            }
          }
        }
      })
    },
    getNowDate () { // 获取当前日期
      let date = new Date()
      let seperator1 = '-'
      let year = date.getFullYear()
      let month = date.getMonth() + 1
      let strDate = date.getDate()
      if (month >= 1 && month <= 9) {
        month = '0' + month
      }
      if (strDate >= 0 && strDate <= 9) {
        strDate = '0' + strDate
      }
      let currentdate = year + seperator1 + month + seperator1 + strDate
      return currentdate
    },
    savePersonalExp () { // 保存个人经历
      const that = this
      for (let i in that.expObject) {
        if (!validatenull(that.expObject[i].name)) {
          if (validatenull(that.expObject[i].value) || that.expObject[i].value === '请选择' || that.expObject[i].type < 0) {
            that.showModal = true
            // that.modalWord = that.expObject[i].name + '信息有误'
            that.expObject[i].error = true
            setTimeout(() => {
              that.showModal = false
            }, 2000)
            return
          }
          that.expObject[i].error = false
        }
      }
      let nowDate = that.getNowDate()
      if (that.expObject.startTime.value > nowDate || that.expObject.endTime.value > nowDate) {
        modal.toast({
          message: '选择日期不能比当前日期晚',
          duration: 0.8
        })
        return
      }
      if (that.expObject.startTime.value >= that.expObject.endTime.value) {
        modal.toast({
          message: '开始日期不能比结束日期晚',
          duration: 0.8
        })
        return
      }
      let params = {
        companyName: that.expObject.companyName.value,
        positionName: that.expObject.positionName.value,
        startTime: that.expObject.startTime.value,
        endTime: that.expObject.endTime.value,
        workPlace: that.expObject.workPlace.value,
        workContent: that.expObject.workContent
      }
      let url = addPersonalExp
      if (!validatenull(that.expId)) {
        params.id = that.expId
        url = modifyPersonalExp
      }
      that.loadingShow = true
      that.$api.post(url, params, () => {
        that.loadingShow = false
        modal.toast({
          message: '保存成功',
          duration: 0.8
        })
        that.getPersonalExperience()
      }, () => {
        that.loadingShow = false
      }, true)
    },
    deleteExp () { // 删除经历
      const that = this
      if (validatenull(that.expId)) {
        return
      }
      modal.confirm({
        message: '确定删除该工作经历？',
        okTitle: '确定',
        cancelTitle: '取消'
      }, function (value) {
        if (value === '确定') {
          that.$api.post(deletePersonalExp + that.expId, {}, (res) => {
            modal.toast({
              message: '删除成功',
              duration: 0.8
            })
            that.getPersonalExperience()
          }, () => {}, true)
        }
      })
    },
    handleSubmit () { // 提交
      const that = this
      let params = {}
      if (that.settleItem.value === '4') {
        if (that.chooseDesignerType.value === '请选择' || that.chooseDesignerType.type < 1) {
          that.chooseDesignerType.error = true
          that.modalWord = '请选择身份类型'
          that.showModal = true
          setTimeout(() => {
            that.showModal = false
          }, 800)
          return
        }
        params.designer_type = that.chooseDesignerType.type
      }
      that.chooseDesignerType.error = false
      for (let i in that.dataForm) {
        if (!validatenull(that.dataForm[i].name)) {
          if (validatenull(that.dataForm[i].value) || that.dataForm[i].value === '请选择') {
            that.errorWord = that.dataForm[i].name + '信息不完整'
            that.dataForm[i].error = true
            that.showModal = true
            setTimeout(() => {
              that.showModal = false
            }, 2000)
            return
          }
          that.dataForm[i].error = false
        }
      }
      let obj = {
        type: that.settleItem.value,
        name: that.dataForm.name.value,
        workYear: that.dataForm.workYear.value,
        address: that.dataForm.address.value,
        phone: that.dataForm.phone.value,
        idCard: that.dataForm.idCard.value,
        attachmentIdCardUrl: that.dataForm.idCardFront.value + ',' + that.dataForm.idCardBack.value,
        introductionAchievements: that.dataForm.introduction,
        motto: that.dataForm.motto.value,
        evaluation: that.dataForm.evaluation.value
      }
      params = Object.assign(params, obj)
      that.loadingShow = true
      that.$api.post(personalSettle, params, () => {
        that.loadingShow = false
        let obj = {
          success: true,
          word: '提交成功'
        }
        that.$router.push({path: '/home', query: {obj: obj}})
      }, () => {
        that.loadingShow = false
      }, true)
    },
    typeTouchStart () { // 点击效果
      this.ifPress = true
    },
    typeTouchEnd () {
      this.ifPress = false
    },
    // 提交按钮点击事件
    subStart () {
      this.ifPress = true
    },
    subEnd () {
      this.ifPress = false
    }
  },
  components: {
    Label,
    Check,
    WxcPopup,
    WxcLoading,
    Preview,
    Question,
    IHeader,
    Buttons,
    timeLine,
    Modal
  }
}
</script>

<style scoped>
    .col_464646 {
        color: #464646;
    }
    .fs_28 {
        font-size: 28px;
    }
    .showForm {
        padding-left: 24px;
        padding-right: 24px;
        align-items: center;
        justify-content: space-between;
    }
    .margin_top_70 {
        margin-top: 70px;
    }
    .work-con{
        box-shadow: 1px 1px 45px rgba(43,48,64,0.1) ;
    }
    .text-date{
        color: rgb(70,70,70) !important;
    }
    .beforepress{
        background-color: #fff;
    }
    .afterpress {
        background-color: rgba(43,48,64,0.2);
    }
    .text-highlight-title{
        color: rgb(70,70,70) !important;
    }
    #achieve{
        color: rgb(70,70,70);
        font-size: 28px;
        height: 80px;
        line-height: 85px;
    }
    .no-single {
        padding-top: 20px;
        padding-bottom: 24px;
        flex-wrap: wrap;
        justify-content: flex-start;
    }
    .companyName{
        margin-top: 88px;
    }
    .delete{
        padding-top: 98px;
        padding-bottom: 98px;
        display: flex;
        flex-direction: row;
        justify-content: center;
    }
    .deletetext{
        width: 414px;
        height: 60px;
        border-width: 1px;
        border-color: rgb(43,48,64);
        border-style: solid;
        border-radius: 10px;
        line-height: 60px;
        text-align: center;
    }
    .footerBtn{
        width: 414px;
        height: 60px;
        text-align: center;
        line-height: 60px;
        font-size: 30px;
        color: #fff;
        border-radius: 10px;
        background-image: linear-gradient(to bottom right, #2b3040, #7d88a4);
     }
    .beforerefer{
        background-image: linear-gradient(to bottom right, #2b3040, #7d88a4);
    }
    .afterrefer{
        background-image: linear-gradient(to bottom right, #343741, #8e929d);
    }
    .person-introduce{
        padding-left: 24px;
        padding-right: 24px;
        background-color: #fff;
    }
    .num{
        padding-top: 16px;
        padding-bottom: 48px;
        flex-direction: row;
        justify-content: flex-end;
    }
    .size{
        font-size: 24px;
        color: rgb(206,206,206);
    }
    .gray{
        width: 750px;
        height: 24px;
        background-color: #F5F5F5;
    }
    .footer{
        padding-top: 98px;
        padding-bottom: 127px;
        background-color: #f5f5f5;
        display: flex;
        flex-direction: row;
        justify-content: center;

    }
    .intro-textarea{
        background-color: #F5F5F5;
        padding-top: 15px;
        padding-right: 15px;
        padding-bottom: 30px;
        padding-left: 15px;
        height:205px;
        overflow-y: scroll;
        width: 702px;
        border-radius: 10px;
        font-size: 26px;
    }
    .add-work-experience{
        padding-top: 30px;
        padding-bottom: 30px;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        border-top-width: 1px;
        border-top-style: solid;
        border-top-color: #cecece;
    }
    .worktext{
        font-size: 28px;
        color: rgb(254,203,1);
    }
    .workImg{
        width: 38px;
        height: 38px;
        margin-right: 17px;
    }
    .col_868686 {
        color: #868686;
    }
    .bgc_f5f5f5 {
        background-color: #f5f5f5;
    }
    .bgc_fff {
        background-color: #fff;
    }
    .margin_top_24 {
        margin-top: 24px;
    }
    .flex_row {
        flex-direction: row;
    }
    .border-bottom-cecece {
        border-bottom-width: 1px;
        border-bottom-style: solid;
        border-bottom-color: #cecece;
    }
    .border-bottom-ebebeb {
        border-bottom-width: 1px;
        border-bottom-style: solid;
        border-bottom-color: #ebebeb;
    }
    .item-height {
        height: 88px;
        line-height: 88px;
    }
    .typename{
        padding-right: 44px;
    }
    .infomation-content {
        margin-top: 88px;
        background-color: #f5f5f5;
    }
    .info-cell {
        padding-left: 24px;
        padding-right: 24px;
        justify-content: space-between;
        background-color: #fff;
    }
    .content-tit {
        padding-left: 24px;
        padding-right: 24px;
        color: #a4a4a4;
        font-size: 28px;
    }
    .handleChoose {
        align-items: center;
    }
    .choose-word {
        font-size: 24px;
    }
    .arrow_right_small {
        width: 27px;
        height: 28px;
        margin-left: 16px;
    }
    .enterprise-item {
        padding-left: 24px;
        padding-right: 24px;
    }
    .enterprise-name {
        font-size: 26px;
    }
    .write {
        padding-right: 44px;
        text-align: right;
        border-width: 0px;
        font-size: 26px;
        placeholder-color: #cecece;
    }
    .enterpriseName {
        width: 512px;
    }
    .enterpriseNumber {
        width: 305px;
    }
    .enterprise-list{
        margin-top: 88px;
        min-height: 500px;
    }
    .intro-tit {
        font-size: 28px;
        color: #464646;
    }
    .idCardImage-container {
        width: 702px;
        margin-top: 20px;
        justify-content: space-between;
    }
    .idCardImage-box {
        width: 340px;
        height: 215px;
    }
    .idCardImage-upload {
        width: 340px;
        height: 215px;
        border-width: 1px;
        border-style: solid;
        border-color: #cecece;
        border-radius: 10px;
        flex-wrap: wrap;
        justify-content: center;
    }
    .image-upload {
        width: 50px;
        height: 50px;
        margin-top: 60px;
        margin-bottom: 20px;
    }
    .upload-word {
        width: 338px;
        text-align: center;
        font-size: 26px;
        color: #cecece;
    }
    .popup-box {
        margin-top: 88px;
        padding-top: 40px;
        padding-left: 24px;
        padding-right: 24px;
        padding-bottom: 24px;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    .example-image {
        width: 300px;
        height: 300px;
    }
    .example-tip {
        width: 700px;
        margin-top: 20px;
        padding-bottom: 24px;
    }
    .tip-header {
        margin-bottom: 16px;
        font-size: 30px;
        font-weight: bold;
        color: #464646;
    }
    .tip-item {
        font-size: 30px;
        line-height: 46px;
        color: #666;
    }
</style>
